package me.joshua.demo4j.spring.data.jpa.first;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

@Entity
@Table(name = "user")
public class UserModel implements Serializable {

	private static final long serialVersionUID = 7701720525717305162L;

	public UserModel() {
	}

	public UserModel(String name) {
		super();
		this.name = name;
		this.registerTime = new Date();
	}

	@Id
	@GeneratedValue
	private Integer id;
	@Column(nullable = false)
	private String name;
	@Column(name = "register_time")
	private Date registerTime;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Date getRegisterTime() {
		return registerTime;
	}

	public void setRegisterTime(Date registerTime) {
		this.registerTime = registerTime;
	}

	@Override
	public String toString() {
		return ToStringBuilder
				.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
	}
}
